/*
 * 
 * LegendShop 多用户商城系统
 * 
 *  版权所有,并保留所有权利。
 * 
 */
package com.legendshop.oa.service.impl;

import java.util.List;

import com.legendshop.dao.support.CriteriaQuery;
import com.legendshop.dao.support.PageSupport;
import com.legendshop.oa.dao.DepartmentDao;
import com.legendshop.oa.model.Department;
import com.legendshop.oa.service.DepartmentService;
import com.legendshop.util.AppUtils;

/**
 * 部门服务.
 */
public class DepartmentServiceImpl  implements DepartmentService{
    private DepartmentDao departmentDao;

    public void setDepartmentDao(DepartmentDao departmentDao) {
        this.departmentDao = departmentDao;
    }

    public List<Department> getDepartment(String userName) {
        return departmentDao.getDepartment(userName);
    }

    public Department getDepartment(Long id) {
        return departmentDao.getDepartment(id);
    }

    public void deleteDepartment(Department department) {
        departmentDao.deleteDepartment(department);
    }

    public Long saveDepartment(Department department) {
        if (!AppUtils.isBlank(department.getId())) {
            updateDepartment(department);
            return department.getId();
        }
        return departmentDao.saveDepartment(department);
    }

    public void updateDepartment(Department department) {
        departmentDao.updateDepartment(department);
    }

    public PageSupport getDepartment(CriteriaQuery cq) {
        return departmentDao.getDepartment(cq);
    }

	@Override
	public List<Department> getAllDepartment() {
		return departmentDao.getAllDepartment();
	}

	@Override
	public String getDepartmentName(Long deptId) {
		return departmentDao.getDepartmentName(deptId);
	}
}
